// $ANTLR 3.3 Nov 30, 2010 12:45:30 D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g 2013-09-13 09:15:03

package org.moflon.moca.blip.unparser.android;


import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

import org.antlr.stringtemplate.*;
import org.antlr.stringtemplate.language.*;
import java.util.HashMap;
public class JavaTreeGrammar extends TreeParser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "ID", "STRING", "ATTRIBUTE", "'JAVA'", "'Package'", "'Imports'", "'Entity'", "'Attribute'"
    };
    public static final int EOF=-1;
    public static final int T__7=7;
    public static final int T__8=8;
    public static final int T__9=9;
    public static final int T__10=10;
    public static final int T__11=11;
    public static final int ID=4;
    public static final int STRING=5;
    public static final int ATTRIBUTE=6;

    // delegates
    // delegators


        public JavaTreeGrammar(TreeNodeStream input) {
            this(input, new RecognizerSharedState());
        }
        public JavaTreeGrammar(TreeNodeStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected StringTemplateGroup templateLib =
      new StringTemplateGroup("JavaTreeGrammarTemplates", AngleBracketTemplateLexer.class);

    public void setTemplateLib(StringTemplateGroup templateLib) {
      this.templateLib = templateLib;
    }
    public StringTemplateGroup getTemplateLib() {
      return templateLib;
    }
    /** allows convenient multi-value initialization:
     *  "new STAttrMap().put(...).put(...)"
     */
    public static class STAttrMap extends HashMap {
      public STAttrMap put(String attrName, Object value) {
        super.put(attrName, value);
        return this;
      }
      public STAttrMap put(String attrName, int value) {
        super.put(attrName, new Integer(value));
        return this;
      }
    }

    public String[] getTokenNames() { return JavaTreeGrammar.tokenNames; }
    public String getGrammarFileName() { return "D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g"; }


    	public Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow)	throws RecognitionException  {
    		try {
            		return super.recoverFromMismatchedToken(input, ttype, follow);
                } catch(java.util.NoSuchElementException e){
                    throw new IllegalArgumentException("Your tree does not comply with your tree grammar!\n"
                    		+ " Problems encountered at: [" + "..." + getTreeNodeStream().LT(-1) + " " 
                    		+ getTreeNodeStream().LT(1) + "..." + "] in tree.");
    		}
        }


    public static class main_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "main"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:34:1: main : ^( 'JAVA' values+= pkgName values+= imports values+= entity ) -> main(values=$values);
    public final JavaTreeGrammar.main_return main() throws RecognitionException {
        JavaTreeGrammar.main_return retval = new JavaTreeGrammar.main_return();
        retval.start = input.LT(1);

        List list_values=null;
        RuleReturnScope values = null;
        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:34:5: ( ^( 'JAVA' values+= pkgName values+= imports values+= entity ) -> main(values=$values))
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:34:7: ^( 'JAVA' values+= pkgName values+= imports values+= entity )
            {
            match(input,7,FOLLOW_7_in_main86); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_pkgName_in_main90);
            values=pkgName();

            state._fsp--;

            if (list_values==null) list_values=new ArrayList();
            list_values.add(values.getTemplate());

            pushFollow(FOLLOW_imports_in_main94);
            values=imports();

            state._fsp--;

            if (list_values==null) list_values=new ArrayList();
            list_values.add(values.getTemplate());

            pushFollow(FOLLOW_entity_in_main98);
            values=entity();

            state._fsp--;

            if (list_values==null) list_values=new ArrayList();
            list_values.add(values.getTemplate());


            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 35:2: -> main(values=$values)
            {
                retval.st = templateLib.getInstanceOf("main",
              new STAttrMap().put("values", list_values));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "main"

    public static class pkgName_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "pkgName"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:37:1: pkgName : ^( 'Package' ^( ATTRIBUTE name= ID packageName= STRING ) ) -> package(packageName=$packageName);
    public final JavaTreeGrammar.pkgName_return pkgName() throws RecognitionException {
        JavaTreeGrammar.pkgName_return retval = new JavaTreeGrammar.pkgName_return();
        retval.start = input.LT(1);

        CommonTree name=null;
        CommonTree packageName=null;

        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:37:8: ( ^( 'Package' ^( ATTRIBUTE name= ID packageName= STRING ) ) -> package(packageName=$packageName))
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:37:10: ^( 'Package' ^( ATTRIBUTE name= ID packageName= STRING ) )
            {
            match(input,8,FOLLOW_8_in_pkgName119); 

            match(input, Token.DOWN, null); 
            match(input,ATTRIBUTE,FOLLOW_ATTRIBUTE_in_pkgName126); 

            match(input, Token.DOWN, null); 
            name=(CommonTree)match(input,ID,FOLLOW_ID_in_pkgName130); 
            packageName=(CommonTree)match(input,STRING,FOLLOW_STRING_in_pkgName134); 

            match(input, Token.UP, null); 

            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 39:2: -> package(packageName=$packageName)
            {
                retval.st = templateLib.getInstanceOf("package",
              new STAttrMap().put("packageName", packageName));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "pkgName"

    public static class imports_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "imports"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:41:1: imports : ^( 'Imports' (imps+= STRING )* ) -> imports(imps=$imps);
    public final JavaTreeGrammar.imports_return imports() throws RecognitionException {
        JavaTreeGrammar.imports_return retval = new JavaTreeGrammar.imports_return();
        retval.start = input.LT(1);

        CommonTree imps=null;
        List list_imps=null;

        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:41:8: ( ^( 'Imports' (imps+= STRING )* ) -> imports(imps=$imps))
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:41:10: ^( 'Imports' (imps+= STRING )* )
            {
            match(input,9,FOLLOW_9_in_imports156); 

            if ( input.LA(1)==Token.DOWN ) {
                match(input, Token.DOWN, null); 
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:41:26: (imps+= STRING )*
                loop1:
                do {
                    int alt1=2;
                    int LA1_0 = input.LA(1);

                    if ( (LA1_0==STRING) ) {
                        alt1=1;
                    }


                    switch (alt1) {
                	case 1 :
                	    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:41:26: imps+= STRING
                	    {
                	    imps=(CommonTree)match(input,STRING,FOLLOW_STRING_in_imports160); 
                	    if (list_imps==null) list_imps=new ArrayList();
                	    list_imps.add(imps);


                	    }
                	    break;

                	default :
                	    break loop1;
                    }
                } while (true);


                match(input, Token.UP, null); 
            }


            // TEMPLATE REWRITE
            // 42:2: -> imports(imps=$imps)
            {
                retval.st = templateLib.getInstanceOf("imports",
              new STAttrMap().put("imps", list_imps));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "imports"

    public static class entity_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "entity"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:44:1: entity : ^( 'Entity' ^( ATTRIBUTE name= ID cName= STRING ) (attrs+= attribute )* ) -> entity(cName=$cNameattrs=$attrs);
    public final JavaTreeGrammar.entity_return entity() throws RecognitionException {
        JavaTreeGrammar.entity_return retval = new JavaTreeGrammar.entity_return();
        retval.start = input.LT(1);

        CommonTree name=null;
        CommonTree cName=null;
        List list_attrs=null;
        RuleReturnScope attrs = null;
        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:44:7: ( ^( 'Entity' ^( ATTRIBUTE name= ID cName= STRING ) (attrs+= attribute )* ) -> entity(cName=$cNameattrs=$attrs))
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:44:9: ^( 'Entity' ^( ATTRIBUTE name= ID cName= STRING ) (attrs+= attribute )* )
            {
            match(input,10,FOLLOW_10_in_entity182); 

            match(input, Token.DOWN, null); 
            match(input,ATTRIBUTE,FOLLOW_ATTRIBUTE_in_entity185); 

            match(input, Token.DOWN, null); 
            name=(CommonTree)match(input,ID,FOLLOW_ID_in_entity189); 
            cName=(CommonTree)match(input,STRING,FOLLOW_STRING_in_entity193); 

            match(input, Token.UP, null); 
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:44:59: (attrs+= attribute )*
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( (LA2_0==11) ) {
                    alt2=1;
                }


                switch (alt2) {
            	case 1 :
            	    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:44:59: attrs+= attribute
            	    {
            	    pushFollow(FOLLOW_attribute_in_entity198);
            	    attrs=attribute();

            	    state._fsp--;

            	    if (list_attrs==null) list_attrs=new ArrayList();
            	    list_attrs.add(attrs.getTemplate());


            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);


            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 45:2: -> entity(cName=$cNameattrs=$attrs)
            {
                retval.st = templateLib.getInstanceOf("entity",
              new STAttrMap().put("cName", cName).put("attrs", list_attrs));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "entity"

    public static class attribute_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "attribute"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:47:1: attribute : ^( 'Attribute' ^( ATTRIBUTE idName= ID name= STRING ) ^( ATTRIBUTE idName= ID firstUpperName= STRING ) ^( ATTRIBUTE idType= ID type= STRING ) ) -> attribute(name=$namefirstUpperName=$firstUpperNametype=$type);
    public final JavaTreeGrammar.attribute_return attribute() throws RecognitionException {
        JavaTreeGrammar.attribute_return retval = new JavaTreeGrammar.attribute_return();
        retval.start = input.LT(1);

        CommonTree idName=null;
        CommonTree name=null;
        CommonTree firstUpperName=null;
        CommonTree idType=null;
        CommonTree type=null;

        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:47:10: ( ^( 'Attribute' ^( ATTRIBUTE idName= ID name= STRING ) ^( ATTRIBUTE idName= ID firstUpperName= STRING ) ^( ATTRIBUTE idType= ID type= STRING ) ) -> attribute(name=$namefirstUpperName=$firstUpperNametype=$type))
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\JavaTreeGrammar.g:47:12: ^( 'Attribute' ^( ATTRIBUTE idName= ID name= STRING ) ^( ATTRIBUTE idName= ID firstUpperName= STRING ) ^( ATTRIBUTE idType= ID type= STRING ) )
            {
            match(input,11,FOLLOW_11_in_attribute225); 

            match(input, Token.DOWN, null); 
            match(input,ATTRIBUTE,FOLLOW_ATTRIBUTE_in_attribute231); 

            match(input, Token.DOWN, null); 
            idName=(CommonTree)match(input,ID,FOLLOW_ID_in_attribute235); 
            name=(CommonTree)match(input,STRING,FOLLOW_STRING_in_attribute239); 

            match(input, Token.UP, null); 
            match(input,ATTRIBUTE,FOLLOW_ATTRIBUTE_in_attribute245); 

            match(input, Token.DOWN, null); 
            idName=(CommonTree)match(input,ID,FOLLOW_ID_in_attribute249); 
            firstUpperName=(CommonTree)match(input,STRING,FOLLOW_STRING_in_attribute253); 

            match(input, Token.UP, null); 
            match(input,ATTRIBUTE,FOLLOW_ATTRIBUTE_in_attribute259); 

            match(input, Token.DOWN, null); 
            idType=(CommonTree)match(input,ID,FOLLOW_ID_in_attribute263); 
            type=(CommonTree)match(input,STRING,FOLLOW_STRING_in_attribute267); 

            match(input, Token.UP, null); 

            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 51:2: -> attribute(name=$namefirstUpperName=$firstUpperNametype=$type)
            {
                retval.st = templateLib.getInstanceOf("attribute",
              new STAttrMap().put("name", name).put("firstUpperName", firstUpperName).put("type", type));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "attribute"

    // Delegated rules


 

    public static final BitSet FOLLOW_7_in_main86 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_pkgName_in_main90 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_imports_in_main94 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_entity_in_main98 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_8_in_pkgName119 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ATTRIBUTE_in_pkgName126 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_pkgName130 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_STRING_in_pkgName134 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_9_in_imports156 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_STRING_in_imports160 = new BitSet(new long[]{0x0000000000000028L});
    public static final BitSet FOLLOW_10_in_entity182 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ATTRIBUTE_in_entity185 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_entity189 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_STRING_in_entity193 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_attribute_in_entity198 = new BitSet(new long[]{0x0000000000000808L});
    public static final BitSet FOLLOW_11_in_attribute225 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ATTRIBUTE_in_attribute231 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_attribute235 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_STRING_in_attribute239 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ATTRIBUTE_in_attribute245 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_attribute249 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_STRING_in_attribute253 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ATTRIBUTE_in_attribute259 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_attribute263 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_STRING_in_attribute267 = new BitSet(new long[]{0x0000000000000008L});

}